package modify;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import util.JdbcUtil;

public class Alter {
	private Connection conn = null;
	private Statement s = null;
	private ResultSet rs = null;
	private int id;
	
	public Alter()
	{
	}

	public Alter(int id) {
		this.id = id;
		conn = JdbcUtil.getConnection();
		try {
			s = conn.createStatement();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void changeDet(String MA, String PA, String PRIMAR, String MIDDLE,
			String HIGH, String FOOD) {
		try {
			String sql = "update detail_info set MA='" + MA + "',PA='" + PA
					+ "',PRIMAR='" + PRIMAR + "',MIDDLE='" + MIDDLE
					+ "',HIGH='" + HIGH + "',FOOD='" + FOOD + "' where SchID="
					+ id;
			//System.out.println(sql);
			s.executeUpdate(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JdbcUtil.release(conn, s, rs);
		}
	}

	public void changeMai(String QQ, String TEL, String MAIL, String LOCAL,
			String SEX, java.sql.Date BIRTH) {
		try {
			String sql = "update main_info set QQ='" + QQ + "',TEL='" + TEL
					+ "',MAIL='" + MAIL + "',LOCAL='" + LOCAL + "',SEX='" + SEX
					+ "',BIRTH='" + BIRTH + "' where SchID=" + id;
			s.executeUpdate(sql);
			//System.out.println(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JdbcUtil.release(conn, s, rs);
		}
	}

	public void changrPass(String pass) {
		try {
			String sql = "update main_info set PSW='" + pass + "' where SchID="
					+ id;
			s.executeUpdate(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JdbcUtil.release(conn, s, rs);
		}
	}

//	@SuppressWarnings("deprecation")
//	public static void main(String[] args) {
//		Alter b = new Alter(24);
//		Alter a = new Alter(25);
//
//		java.sql.Date bir = new java.sql.Date(93, 06, 28);
//		a.changeMai("3333", "4444", "5555", "6666", "7777", bir);
//		b.changrPass("eee");
//	}
}
